function createMap(latitude,longitude,mapContainerId,zoom,mapType,allowScroll){google.maps.visualRefresh=true;var googleMapType;switch(mapType){case "roadmap":googleMapType=google.maps.MapTypeId.ROADMAP;break;case "terrain":googleMapType=google.maps.MapTypeId.TERRAIN;break;case "hybrid":googleMapType=google.maps.MapTypeId.HYBRID;break;case "satellite":default:googleMapType=google.maps.MapTypeId.SATELLITE;break;} var mapOptions={scrollwheel:allowScroll,zoom:zoom,center:new google.maps.LatLng(latitude,longitude),mapTypeId:googleMapType};map=new google.maps.Map(document.getElementById(mapContainerId),mapOptions);return map;};var bounds=new google.maps.LatLngBounds();function createMarker(map,latitude,longitude,dragabble,draggingCallBack,markerIconUrl,fitBounds,clickable,clickCallBack,identifier){var markerOptions={map:map,position:new google.maps.LatLng(latitude,longitude),dragabble:dragabble==null?false:dragabble,icon:markerIconUrl.length>0?markerIconUrl:""};var marker=new google.maps.Marker(markerOptions);if(identifier) marker.set("identifier",identifier) if(dragabble&&draggingCallBack!=null){google.maps.event.addListener(marker,'dragend',function(){draggingCallBack(marker.getPosition());});} if(clickable&&clickCallBack!=null){google.maps.event.addListener(marker,'click',function(){clickCallBack(marker.identifier);});} if(fitBounds){bounds.extend(marker.getPosition());map.fitBounds(bounds);} if(!fitBounds){map.setCenter(bounds);map.setZoom(13);} return marker;};function drawingOptions(strokeColor,strokeOpacity,strokeWeight,fillColor,fillOpacity){this.strokeColor=strokeColor==null?'#FF0000':strokeColor;this.strokeOpacity=strokeOpacity==null?0.8:strokeOpacity;this.strokeWeight=strokeWeight==null?2:strokeWeight;this.fillColor=fillColor==null?'#FF0000':fillColor;this.fillOpacity=fillOpacity==null?0.35:fillOpacity;return this;} function drawCircle(map,latitude,longitude,radius,unit,drawingOptions,fitMapBoundsToCircle){if(isNaN(radius)){alert("Invalid Radius, must be a valid number");return;} var circleUnit;switch(unit){case "miles":radius=radius*1609.34;break;case "kilometers":radius=radius*1000;break;case "meters":default:break;} var circleOptions={strokeColor:drawingOptions.strokeColor,strokeOpacity:drawingOptions.strokeOpacity,strokeWeight:drawingOptions.strokeWeight,fillColor:drawingOptions.fillColor,fillOpacity:drawingOptions.fillOpacity,map:map,center:new google.maps.LatLng(latitude,longitude),radius:parseInt(radius)};var circle=new google.maps.Circle(circleOptions);if(fitMapBoundsToCircle===true){map.fitBounds(circle.getBounds());} return circle;};function removeCircle(circle){circle.setMap(null);} function removeMarker(marker){marker.setMap(null);} function islocatedInsidePolygon(latitude,longitude,polygon){var point=new google.maps.LatLng(latitude,longitude);var polygonBounds=polygon.getBounds();return polygonBounds.contains(point);} function calculateDistance(point1latitude,point1longitude,point2latitude,point2longitude,mode,callBackfunction){var point1=new google.maps.LatLng(point1latitude,point1longitude);var point2=new google.maps.LatLng(point2latitude,point2longitude);if(mode=="straightLine"||mode=='undefined'){return(google.maps.geometry.spherical.computeDistanceBetween(point1,point2)/1000).toFixed(2);} else{var service=new google.maps.DistanceMatrixService();service.getDistanceMatrix({origins:[point1],destinations:[point2],travelMode:google.maps.TravelMode.DRIVING,unitSystem:google.maps.UnitSystem.METRIC,avoidHighways:false,avoidTolls:false},callback);}} function geocodeLocation(address,callback){var geocoder=new google.maps.Geocoder();geocoder.geocode({'address':address},function(results,status){if(status==google.maps.GeocoderStatus.OK){callback(results[0].geometry.location);}else{alert('Geocode was not successful for the following reason: '+status);}});}